package NGUYENNGOCHUNG;

import java.util.Scanner; // thieu phan thong bao nguoi dung chua nhap gia tri a va b

public class BaiTap02TinhToan {
	public static void main(String[] args) {
		System.out.println("Bai tap tinh toan cong, tru, nhan, chia. ");
		System.out.println("1. Phep tinh cong : a + b ");
		System.out.println("2. Phep tinh tru: a - b ");
		System.out.println("3. Phep tinh nhan: a * b ");
		System.out.println("4. Phep tinh chia: a / b ");

		Scanner scan = new Scanner(System.in);	
		System.out.println("Vui long nhap so a: ");
		String empty = scan.nextLine();		
		if (empty.isEmpty()) {
			System.out.println("Ban chua nhap vao so a.");
			return;
		}else{
			
		}
		int a = Integer.parseInt(empty);

		scan = new Scanner(System.in);
		System.out.println("Vui long nhap so b: ");
		empty = scan.nextLine();		
		if (empty.isEmpty()) {
			System.out.println("Ban chua nhap vao so b.");
			return;
		}else{
			
		}
		int b = Integer.parseInt(empty);

		if (a == 0 && b == 0) {
			System.out.println("Result of function is underfined");
		} else if (a != 0 && b == 0) {
			System.out.println("Cannot divide by zero");
		} else if (a != 0 & b != 0) {

			scan = new Scanner(System.in);
			System.out.println("Vui long chon phep tinh ban muon thuc hien.");
			int op1 = scan.nextInt();

			if (op1 == 1) {
				System.out.println("Ban da chon phep tinh cong.");
				System.out.println("Ket qua cua phep tinh la: " + (a + b));
			} else if (op1 == 2) {
				System.out.println("Ban da chon phep tinh tru.");
				System.out.println("Ket qua cua phep tinh la: " + (a - b));
			} else if (op1 == 3) {
				System.out.println("Ban da chon phep tinh nhan.");
				System.out.println("Ket qua cua phep tinh la: " + (a * b));
			} else if (op1 == 4) {
				System.out.println("Ban da chon phep tinh chia.");
				System.out.println("Ket qua cua phep tinh la: " + (a / b));
			} else if (op1 != 1 && op1 != 2 && op1 != 3 && op1 != 4) {
				System.out
						.println("Ban chua chon bat ky phep tinh nao. vui long chon lai.");
			} else {

			}
		} else {

		}

	}
}
